package com.itttq.kb.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.itttq.kb.model.to.PageParamTo;
import com.itttq.kb.model.po.TopicCategoryPo;
import com.itttq.kb.mapper.ITopicCategoryMapper;

@Service
public class TopicCategoryService {
	@Autowired
	private ITopicCategoryMapper topicCategoryMapper;
	
	public TopicCategoryPo getTopicCategory(int id) {
		TopicCategoryPo topicCategory = new TopicCategoryPo();
		topicCategory.setId(id);
		return topicCategoryMapper.findById(topicCategory);
	}

	public List<TopicCategoryPo> getTopicCategorys(TopicCategoryPo topicCategory, PageParamTo ppt) {
		return topicCategoryMapper.find4page(topicCategory, ppt);
	}

	public int getTopicCategoryCount(TopicCategoryPo topicCategory) {
		return topicCategoryMapper.getCount(topicCategory);
	}

	public void delTopicCategory(int id) {
		TopicCategoryPo topicCategory = new TopicCategoryPo();
		topicCategory.setId(id);
		topicCategoryMapper.delete(topicCategory);
	}

	public void addTopicCategory(TopicCategoryPo topicCategory) {
		topicCategoryMapper.insert(topicCategory);
	}
	
	public void updateTopicCategory(TopicCategoryPo topicCategory) {
		topicCategoryMapper.update(topicCategory);
	}
}
